#include "tx_api.h"
#include "nx_api.h"
                      
extern void test_control_return(UINT status);
#if defined (FEATURE_NX_IPV6) && defined(NX_ENABLE_INTERFACE_CAPABILITY)
#include "nx_udp.h"
#include "nx_ip.h"
#include "nx_ipv6.h"
#include "nxd_dhcpv6_client.h"   

#define DEMO_STACK_SIZE         2048
#define DHCPV6_IANA_ID          0x165c19da

static TX_THREAD                dhcpv6_client_thread;
static NX_PACKET_POOL           pool_0;
static NX_IP                    ip_0;
static NX_DHCPV6                dhcp_client;
                                                
static CHAR                     *pointer;
static ULONG                    error_counter;

static UCHAR                    bound_flag = NX_FALSE;
static UCHAR                    renew_flag = NX_FALSE;
                                                             
/* Define thread prototypes.  */

static void dhcpv6_client_thread_entry(ULONG thread_input);
extern void _nx_ram_network_driver_1500(struct NX_IP_DRIVER_STRUCT *driver_req);
extern UINT (*packet_process_callback)(NX_IP *ip_ptr, NX_PACKET *packet_ptr);       
static UINT my_packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr);   
static VOID dhcpv6_server_packet_response(UINT transaction_id, UINT packet_index);   
static VOID dhcpv6_state_change_notify(NX_DHCPV6 *dhcpv6_ptr, UINT old_state, UINT new_state);

#if 0
  /* Frame (130 bytes) */
static const unsigned char pkt1[130] = {
0x33, 0x33, 0x00, 0x01, 0x00, 0x02, 0xaa, 0xab, /* 33...... */
0xac, 0x6e, 0x57, 0xdd, 0x86, 0xdd, 0x60, 0x00, /* .nW...`. */
0x00, 0x00, 0x00, 0x4c, 0x11, 0x40, 0xfe, 0x80, /* ...L.@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0xff, 0x02, /* ...nW... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, /* ......." */
0x02, 0x23, 0x00, 0x4c, 0x15, 0x8e, 0x01, 0xcb, /* .#.L.... */
0x5d, 0x95, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, /* ]....... */
0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, 0xaa, 0xab, /* .....&.. */
0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, 0x00, 0x0c, /* .nW..... */
0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, 0x00, 0x00, /* .\...... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x02, /* ........ */
0x00, 0x00, 0x00, 0x27, 0x00, 0x0c, 0x00, 0x09, /* ...'.... */
0x4d, 0x79, 0x2d, 0x44, 0x65, 0x76, 0x69, 0x63, /* My-Devic */
0x65, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, 0x17, /* e....... */
0x00, 0x27                                      /* .' */
};
#endif

/* Frame (198 bytes) */
static const unsigned char pkt2[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x50, /* ...nW..P */
0xda, 0xc6, 0x5a, 0x48, 0x86, 0xdd, 0x60, 0x00, /* ..ZH..`. */
0x00, 0x00, 0x00, 0x90, 0x11, 0x40, 0x12, 0x34, /* .....@.4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x80, 0xb1, 0x02, 0xcb, /* ."...... */
0x5d, 0x95, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ]....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (198 bytes) */
static const unsigned char pkt3[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x1f, /* ...nW... */
0x9e, 0x5b, 0x74, 0x02, 0x86, 0xdd, 0x6e, 0x00, /* .[t...n. */
0x00, 0x00, 0x00, 0x90, 0x11, 0xff, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f, /* ........ */
0x9e, 0xff, 0xfe, 0x5b, 0x74, 0x02, 0xfe, 0x80, /* ...[t... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x81, 0xe5, 0x02, 0xcb, /* ."...... */
0x5d, 0x95, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ]....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

#if 0
/* Frame (176 bytes) */
static const unsigned char pkt4[176] = {
0x33, 0x33, 0x00, 0x01, 0x00, 0x02, 0xaa, 0xab, /* 33...... */
0xac, 0x6e, 0x57, 0xdd, 0x86, 0xdd, 0x60, 0x00, /* .nW...`. */
0x00, 0x00, 0x00, 0x7a, 0x11, 0x40, 0xfe, 0x80, /* ...z.@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0xff, 0x02, /* ...nW... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, /* ......." */
0x02, 0x23, 0x00, 0x7a, 0x84, 0x9b, 0x03, 0x22, /* .#.z..." */
0x2c, 0x93, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, /* ,....... */
0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, 0xaa, 0xab, /* .....&.. */
0xac, 0x6e, 0x57, 0xdd, 0x00, 0x08, 0x00, 0x02, /* .nW..... */
0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x03, 0x00, 0x28, /* k..z...( */
0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, 0x00, 0x1e, /* .\...... */
0x00, 0x00, 0x00, 0x30, 0x00, 0x05, 0x00, 0x18, /* ...0.... */
0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* .4...... */
0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, 0xaf, 0x72, /* .Z...|.r */
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, /* ...<...x */
0x00, 0x27, 0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, /* .'....My */
0x2d, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x00, /* -Device. */
0x00, 0x06, 0x00, 0x04, 0x00, 0x17, 0x00, 0x27  /* .......' */
};
#endif

/* Frame (198 bytes) */
static const unsigned char pkt5[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x50, /* ...nW..P */
0xda, 0xc6, 0x5a, 0x48, 0x86, 0xdd, 0x60, 0x00, /* ..ZH..`. */
0x00, 0x00, 0x00, 0x90, 0x11, 0x40, 0x12, 0x34, /* .....@.4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0xad, 0x5c, 0x07, 0x22, /* ."...\." */
0x2c, 0x93, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ,....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (198 bytes) */
static const unsigned char pkt6[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x1f, /* ...nW... */
0x9e, 0x5b, 0x74, 0x02, 0x86, 0xdd, 0x6e, 0x00, /* .[t...n. */
0x00, 0x00, 0x00, 0x90, 0x11, 0xff, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f, /* ........ */
0x9e, 0xff, 0xfe, 0x5b, 0x74, 0x02, 0xfe, 0x80, /* ...[t... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0xae, 0x90, 0x07, 0x22, /* ."....." */
0x2c, 0x93, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ,....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

#if 0
/* Frame (176 bytes) */
static const unsigned char pkt7[176] = {
0x33, 0x33, 0x00, 0x01, 0x00, 0x02, 0xaa, 0xab, /* 33...... */
0xac, 0x6e, 0x57, 0xdd, 0x86, 0xdd, 0x60, 0x00, /* .nW...`. */
0x00, 0x00, 0x00, 0x7a, 0x11, 0x40, 0xfe, 0x80, /* ...z.@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0xff, 0x02, /* ...nW... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, /* ......." */
0x02, 0x23, 0x00, 0x7a, 0xf9, 0x6f, 0x05, 0x2f, /* .#.z.o./ */
0xb5, 0xb1, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, 0xaa, 0xab, /* .....&.. */
0xac, 0x6e, 0x57, 0xdd, 0x00, 0x08, 0x00, 0x02, /* .nW..... */
0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x03, 0x00, 0x28, /* k..z...( */
0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, 0x00, 0x1e, /* .\...... */
0x00, 0x00, 0x00, 0x30, 0x00, 0x05, 0x00, 0x18, /* ...0.... */
0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* .4...... */
0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, 0xaf, 0x72, /* .Z...|.r */
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, /* ...<...x */
0x00, 0x27, 0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, /* .'....My */
0x2d, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x00, /* -Device. */
0x00, 0x06, 0x00, 0x04, 0x00, 0x17, 0x00, 0x27  /* .......' */
};
#endif

/* Frame (198 bytes) */
static const unsigned char pkt8[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x50, /* ...nW..P */
0xda, 0xc6, 0x5a, 0x48, 0x86, 0xdd, 0x60, 0x00, /* ..ZH..`. */
0x00, 0x00, 0x00, 0x90, 0x11, 0x40, 0x12, 0x34, /* .....@.4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x24, 0x31, 0x07, 0x2f, /* ."..$1./ */
0xb5, 0xb1, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (198 bytes) */
static const unsigned char pkt9[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x1f, /* ...nW... */
0x9e, 0x5b, 0x74, 0x02, 0x86, 0xdd, 0x6e, 0x00, /* .[t...n. */
0x00, 0x00, 0x00, 0x90, 0x11, 0xff, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f, /* ........ */
0x9e, 0xff, 0xfe, 0x5b, 0x74, 0x02, 0xfe, 0x80, /* ...[t... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x25, 0x65, 0x07, 0x2f, /* ."..%e./ */
0xb5, 0xb1, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

#if 0
/* Frame (176 bytes) */
static const unsigned char pkt10[176] = {
0x33, 0x33, 0x00, 0x01, 0x00, 0x02, 0xaa, 0xab, /* 33...... */
0xac, 0x6e, 0x57, 0xdd, 0x86, 0xdd, 0x60, 0x00, /* .nW...`. */
0x00, 0x00, 0x00, 0x7a, 0x11, 0x40, 0xfe, 0x80, /* ...z.@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0xff, 0x02, /* ...nW... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, /* ......." */
0x02, 0x23, 0x00, 0x7a, 0xf9, 0x6f, 0x05, 0x2f, /* .#.z.o./ */
0xb5, 0xb1, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, 0xaa, 0xab, /* .....&.. */
0xac, 0x6e, 0x57, 0xdd, 0x00, 0x08, 0x00, 0x02, /* .nW..... */
0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x03, 0x00, 0x28, /* k..z...( */
0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, 0x00, 0x1e, /* .\...... */
0x00, 0x00, 0x00, 0x30, 0x00, 0x05, 0x00, 0x18, /* ...0.... */
0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* .4...... */
0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, 0xaf, 0x72, /* .Z...|.r */
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, /* ...<...x */
0x00, 0x27, 0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, /* .'....My */
0x2d, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x00, /* -Device. */
0x00, 0x06, 0x00, 0x04, 0x00, 0x17, 0x00, 0x27  /* .......' */
};

/* Frame (198 bytes) */
static const unsigned char pkt11[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x50, /* ...nW..P */
0xda, 0xc6, 0x5a, 0x48, 0x86, 0xdd, 0x60, 0x00, /* ..ZH..`. */
0x00, 0x00, 0x00, 0x90, 0x11, 0x40, 0x12, 0x34, /* .....@.4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x24, 0x31, 0x07, 0x2f, /* ."..$1./ */
0xb5, 0xb1, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (198 bytes) */
static const unsigned char pkt12[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x1f, /* ...nW... */
0x9e, 0x5b, 0x74, 0x02, 0x86, 0xdd, 0x6e, 0x00, /* .[t...n. */
0x00, 0x00, 0x00, 0x90, 0x11, 0xff, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f, /* ........ */
0x9e, 0xff, 0xfe, 0x5b, 0x74, 0x02, 0xfe, 0x80, /* ...[t... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x25, 0x65, 0x07, 0x2f, /* ."..%e./ */
0xb5, 0xb1, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (176 bytes) */
static const unsigned char pkt13[176] = {
0x33, 0x33, 0x00, 0x01, 0x00, 0x02, 0xaa, 0xab, /* 33...... */
0xac, 0x6e, 0x57, 0xdd, 0x86, 0xdd, 0x60, 0x00, /* .nW...`. */
0x00, 0x00, 0x00, 0x7a, 0x11, 0x40, 0xfe, 0x80, /* ...z.@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0xff, 0x02, /* ...nW... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, /* ......." */
0x02, 0x23, 0x00, 0x7a, 0x68, 0xf3, 0x05, 0x76, /* .#.zh..v */
0x45, 0xe7, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, 0xaa, 0xab, /* .....&.. */
0xac, 0x6e, 0x57, 0xdd, 0x00, 0x08, 0x00, 0x02, /* .nW..... */
0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x03, 0x00, 0x28, /* k..z...( */
0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, 0x00, 0x1e, /* .\...... */
0x00, 0x00, 0x00, 0x30, 0x00, 0x05, 0x00, 0x18, /* ...0.... */
0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* .4...... */
0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, 0xaf, 0x72, /* .Z...|.r */
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, /* ...<...x */
0x00, 0x27, 0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, /* .'....My */
0x2d, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x00, /* -Device. */
0x00, 0x06, 0x00, 0x04, 0x00, 0x17, 0x00, 0x27  /* .......' */
};

/* Frame (198 bytes) */
static const unsigned char pkt14[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x50, /* ...nW..P */
0xda, 0xc6, 0x5a, 0x48, 0x86, 0xdd, 0x60, 0x00, /* ..ZH..`. */
0x00, 0x00, 0x00, 0x90, 0x11, 0x40, 0x12, 0x34, /* .....@.4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x93, 0xb4, 0x07, 0x76, /* .".....v */
0x45, 0xe7, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (198 bytes) */
static const unsigned char pkt15[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x1f, /* ...nW... */
0x9e, 0x5b, 0x74, 0x02, 0x86, 0xdd, 0x6e, 0x00, /* .[t...n. */
0x00, 0x00, 0x00, 0x90, 0x11, 0xff, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f, /* ........ */
0x9e, 0xff, 0xfe, 0x5b, 0x74, 0x02, 0xfe, 0x80, /* ...[t... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x94, 0xe8, 0x07, 0x76, /* .".....v */
0x45, 0xe7, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (176 bytes) */
static const unsigned char pkt16[176] = {
0x33, 0x33, 0x00, 0x01, 0x00, 0x02, 0xaa, 0xab, /* 33...... */
0xac, 0x6e, 0x57, 0xdd, 0x86, 0xdd, 0x60, 0x00, /* .nW...`. */
0x00, 0x00, 0x00, 0x7a, 0x11, 0x40, 0xfe, 0x80, /* ...z.@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0xff, 0x02, /* ...nW... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, /* ......." */
0x02, 0x23, 0x00, 0x7a, 0x68, 0xf3, 0x05, 0x76, /* .#.zh..v */
0x45, 0xe7, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, 0xaa, 0xab, /* .....&.. */
0xac, 0x6e, 0x57, 0xdd, 0x00, 0x08, 0x00, 0x02, /* .nW..... */
0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x03, 0x00, 0x28, /* k..z...( */
0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, 0x00, 0x1e, /* .\...... */
0x00, 0x00, 0x00, 0x30, 0x00, 0x05, 0x00, 0x18, /* ...0.... */
0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* .4...... */
0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, 0xaf, 0x72, /* .Z...|.r */
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, /* ...<...x */
0x00, 0x27, 0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, /* .'....My */
0x2d, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x00, /* -Device. */
0x00, 0x06, 0x00, 0x04, 0x00, 0x17, 0x00, 0x27  /* .......' */
};

/* Frame (198 bytes) */
static const unsigned char pkt17[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x50, /* ...nW..P */
0xda, 0xc6, 0x5a, 0x48, 0x86, 0xdd, 0x60, 0x00, /* ..ZH..`. */
0x00, 0x00, 0x00, 0x90, 0x11, 0x40, 0x12, 0x34, /* .....@.4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x93, 0xb4, 0x07, 0x76, /* .".....v */
0x45, 0xe7, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (198 bytes) */
static const unsigned char pkt18[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x1f, /* ...nW... */
0x9e, 0x5b, 0x74, 0x02, 0x86, 0xdd, 0x6e, 0x00, /* .[t...n. */
0x00, 0x00, 0x00, 0x90, 0x11, 0xff, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f, /* ........ */
0x9e, 0xff, 0xfe, 0x5b, 0x74, 0x02, 0xfe, 0x80, /* ...[t... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x94, 0xe8, 0x07, 0x76, /* .".....v */
0x45, 0xe7, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (176 bytes) */
static const unsigned char pkt19[176] = {
0x33, 0x33, 0x00, 0x01, 0x00, 0x02, 0xaa, 0xab, /* 33...... */
0xac, 0x6e, 0x57, 0xdd, 0x86, 0xdd, 0x60, 0x00, /* .nW...`. */
0x00, 0x00, 0x00, 0x7a, 0x11, 0x40, 0xfe, 0x80, /* ...z.@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0xff, 0x02, /* ...nW... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, /* ......." */
0x02, 0x23, 0x00, 0x7a, 0x68, 0xf3, 0x05, 0x76, /* .#.zh..v */
0x45, 0xe7, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, 0xaa, 0xab, /* .....&.. */
0xac, 0x6e, 0x57, 0xdd, 0x00, 0x08, 0x00, 0x02, /* .nW..... */
0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x03, 0x00, 0x28, /* k..z...( */
0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, 0x00, 0x1e, /* .\...... */
0x00, 0x00, 0x00, 0x30, 0x00, 0x05, 0x00, 0x18, /* ...0.... */
0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* .4...... */
0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, 0xaf, 0x72, /* .Z...|.r */
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, /* ...<...x */
0x00, 0x27, 0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, /* .'....My */
0x2d, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x00, /* -Device. */
0x00, 0x06, 0x00, 0x04, 0x00, 0x17, 0x00, 0x27  /* .......' */
};

/* Frame (198 bytes) */
static const unsigned char pkt20[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x50, /* ...nW..P */
0xda, 0xc6, 0x5a, 0x48, 0x86, 0xdd, 0x60, 0x00, /* ..ZH..`. */
0x00, 0x00, 0x00, 0x90, 0x11, 0x40, 0x12, 0x34, /* .....@.4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x93, 0xb4, 0x07, 0x76, /* .".....v */
0x45, 0xe7, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (198 bytes) */
static const unsigned char pkt21[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x1f, /* ...nW... */
0x9e, 0x5b, 0x74, 0x02, 0x86, 0xdd, 0x6e, 0x00, /* .[t...n. */
0x00, 0x00, 0x00, 0x90, 0x11, 0xff, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f, /* ........ */
0x9e, 0xff, 0xfe, 0x5b, 0x74, 0x02, 0xfe, 0x80, /* ...[t... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x94, 0xe8, 0x07, 0x76, /* .".....v */
0x45, 0xe7, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (176 bytes) */
static const unsigned char pkt22[176] = {
0x33, 0x33, 0x00, 0x01, 0x00, 0x02, 0xaa, 0xab, /* 33...... */
0xac, 0x6e, 0x57, 0xdd, 0x86, 0xdd, 0x60, 0x00, /* .nW...`. */
0x00, 0x00, 0x00, 0x7a, 0x11, 0x40, 0xfe, 0x80, /* ...z.@.. */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0xff, 0x02, /* ...nW... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x22, /* ......." */
0x02, 0x23, 0x00, 0x7a, 0x68, 0xf3, 0x05, 0x76, /* .#.zh..v */
0x45, 0xe7, 0x00, 0x01, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, 0xaa, 0xab, /* .....&.. */
0xac, 0x6e, 0x57, 0xdd, 0x00, 0x08, 0x00, 0x02, /* .nW..... */
0x00, 0x00, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* ........ */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x03, 0x00, 0x28, /* k..z...( */
0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, 0x00, 0x1e, /* .\...... */
0x00, 0x00, 0x00, 0x30, 0x00, 0x05, 0x00, 0x18, /* ...0.... */
0x12, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* .4...... */
0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, 0xaf, 0x72, /* .Z...|.r */
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x78, /* ...<...x */
0x00, 0x27, 0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, /* .'....My */
0x2d, 0x44, 0x65, 0x76, 0x69, 0x63, 0x65, 0x00, /* -Device. */
0x00, 0x06, 0x00, 0x04, 0x00, 0x17, 0x00, 0x27  /* .......' */
};

/* Frame (198 bytes) */
static const unsigned char pkt23[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x50, /* ...nW..P */
0xda, 0xc6, 0x5a, 0x48, 0x86, 0xdd, 0x60, 0x00, /* ..ZH..`. */
0x00, 0x00, 0x00, 0x90, 0x11, 0x40, 0x12, 0x34, /* .....@.4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x93, 0xb4, 0x07, 0x76, /* .".....v */
0x45, 0xe7, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};

/* Frame (198 bytes) */
static const unsigned char pkt24[198] = {
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x1f, /* ...nW... */
0x9e, 0x5b, 0x74, 0x02, 0x86, 0xdd, 0x6e, 0x00, /* .[t...n. */
0x00, 0x00, 0x00, 0x90, 0x11, 0xff, 0xfe, 0x80, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x1f, /* ........ */
0x9e, 0xff, 0xfe, 0x5b, 0x74, 0x02, 0xfe, 0x80, /* ...[t... */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa8, 0xab, /* ........ */
0xac, 0xff, 0xfe, 0x6e, 0x57, 0xdd, 0x02, 0x23, /* ...nW..# */
0x02, 0x22, 0x00, 0x90, 0x94, 0xe8, 0x07, 0x76, /* .".....v */
0x45, 0xe7, 0x00, 0x02, 0x00, 0x0e, 0x00, 0x01, /* E....... */
0x00, 0x01, 0x0f, 0xf4, 0x76, 0x42, 0x00, 0x09, /* ....vB.. */
0x6b, 0x07, 0xa3, 0x7a, 0x00, 0x01, 0x00, 0x0e, /* k..z.... */
0x00, 0x01, 0x00, 0x01, 0x99, 0x0a, 0xb5, 0x26, /* .......& */
0xaa, 0xab, 0xac, 0x6e, 0x57, 0xdd, 0x00, 0x03, /* ...nW... */
0x00, 0x28, 0x16, 0x5c, 0x19, 0xda, 0x00, 0x00, /* .(.\.... */
0x00, 0x1e, 0x00, 0x00, 0x00, 0x30, 0x00, 0x05, /* .....0.. */
0x00, 0x18, 0x12, 0x34, 0x00, 0x00, 0x00, 0x00, /* ...4.... */
0x00, 0x00, 0x0b, 0x5a, 0xbe, 0xb5, 0x9e, 0x7c, /* ...Z...| */
0xaf, 0x72, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, /* .r...<.. */
0x00, 0x78, 0x00, 0x17, 0x00, 0x20, 0x12, 0x34, /* .x... .4 */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0xab, 0xcd, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* ........ */
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x27, /* .......' */
0x00, 0x0c, 0x00, 0x09, 0x4d, 0x79, 0x2d, 0x44, /* ....My-D */
0x65, 0x76, 0x69, 0x63, 0x65, 0x00              /* evice. */
};           
#endif

#ifdef CTEST
VOID test_application_define(void *first_unused_memory)
#else
void netx_dhcpv6_packet_loss_test_application_define(void * first_unused_memory)
#endif
{
UINT            status;

    /* Setup the working pointer.  */
    pointer = (CHAR *) first_unused_memory;

    error_counter = 0;

    /* Initialize the NetX system.  */
    nx_system_initialize();

    /* Create a packet pool.  */
    status = nx_packet_pool_create(&pool_0, "NetX Main Packet Pool", 1536, pointer, 1536*16);
    pointer = pointer + 1536*16;
    if(status)
        error_counter++;

    /* Create an IP instance.  */
    status = nx_ip_create(&ip_0, "NetX IP Instance 0", IP_ADDRESS(1,2,3,4), 0xFFFFFF00UL, &pool_0, _nx_ram_network_driver_1500,
                          pointer, 2048, 1);
    pointer = pointer + 2048;

    /* Enable IPv6 */
    status = nxd_ipv6_enable(&ip_0);
    if(status)
        error_counter++;

    /* Enable ICMP for IP Instance 0 and 1.  */
    status = nxd_icmp_enable(&ip_0);
    if(status)
        error_counter++;

    status = nx_udp_enable(&ip_0);
    if(status)
        error_counter++;

    /* Enable fragment processing for IP Instance 0.  */
    status = nx_ip_fragment_enable(&ip_0);
    if(status)
        error_counter++;    
                 
    /* Create the main thread.  */
    tx_thread_create(&dhcpv6_client_thread, "dhcpv6 client thread", dhcpv6_client_thread_entry, 0,  
                     pointer, DEMO_STACK_SIZE, 
                     4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);

    pointer = pointer + DEMO_STACK_SIZE;       
}

void dhcpv6_client_thread_entry(ULONG thread_input)
{
UINT        status;
                      
                             
    /* Print out test information banner.  */
    printf("NetX Test:   DHCPv6 Packet Loss Test...................................");
                                                                              
    /* Check for earlier error.  */
    if(error_counter)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }       

    /* Set the new physical address.  */
    status = nx_ip_interface_physical_address_set(&ip_0, 0, 0x0000aaab, 0xac6e57dd, NX_TRUE);  

    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }    
          
    /* Set the linklocal address.  */
    status = nxd_ipv6_address_set(&ip_0, 0, NX_NULL, 10, NX_NULL);

    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }    

    /* Wait to finish the DAD. */
    tx_thread_sleep(5 * NX_IP_PERIODIC_RATE);

    /* Create a DHCPv6 Client. */
    status = nx_dhcpv6_client_create(&dhcp_client, &ip_0, "DHCPv6 Client", &pool_0, pointer, 2048, dhcpv6_state_change_notify, NX_NULL);
    pointer += 2048;
                           
    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }       

    /* Create a Link Layer Plus Time DUID for the DHCPv6 Client. Set time ID field 
       to NULL; the DHCPv6 Client API will supply one. */
    status = nx_dhcpv6_create_client_duid(&dhcp_client, NX_DHCPV6_DUID_TYPE_LINK_TIME, NX_DHCPV6_HW_TYPE_IEEE_802, 0x990ab526);   
           
    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }       

    /* Create the DHCPv6 client's Identity Association (IA-NA) now. */
    status = nx_dhcpv6_create_client_iana(&dhcp_client, DHCPV6_IANA_ID, 0xFFFFFFFF,  0xFFFFFFFF); 

    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }       
              
    /* Set the DNS Server option.  */
    status = nx_dhcpv6_request_option_DNS_server(&dhcp_client, NX_TRUE); 
             
    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }       

    /* Set the DHCPv6 Client FQDN option. 
       operation: NX_DHCPV6_CLIENT_DESIRES_UPDATE_AAAA_RR         DHCPv6 Client choose to updating the FQDN-to-IPv6 address mapping for FQDN and address(es) used by the client.  
                  NX_DHCPV6_CLIENT_DESIRES_SERVER_DO_DNS_UPDATE   DHCPv6 Client choose to updating the FQDN-to-IPv6 address mapping for FQDN and address(es) used by the client to the server.  
                  NX_DHCPV6_CLIENT_DESIRES_NO_SERVER_DNS_UPDATE   DHCPv6 Client choose to request that the server perform no DNS updatest on its behalf.  */
    status = nx_dhcpv6_request_option_FQDN(&dhcp_client, "DHCPv6-Client", NX_DHCPV6_CLIENT_DESIRES_UPDATE_AAAA_RR);
               
    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }       

    /* Set the call back function.  */
    packet_process_callback = my_packet_process;
          
    /* Check the available packet.  */
    if (pool_0.nx_packet_pool_available != pool_0.nx_packet_pool_total)     
    {
        printf("ERROR!\n");
        test_control_return(1);
    }       

    /* Start the NetX DHCPv6 Client.  */
    status =  nx_dhcpv6_start(&dhcp_client);   
                                                   
    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }      

    /* Request the IPv6 address.  */
    status = nx_dhcpv6_request_solicit(&dhcp_client);            
                                                                        
    /* Check the status.  */
    if(status)
    {
        printf("ERROR!\n");
        test_control_return(1);
    }

    /* Sleep 40s to detect requesting and renewing operation.  */
    tx_thread_sleep(40 * NX_IP_PERIODIC_RATE);
                         
    /* Check the available packet.  */
    if (pool_0.nx_packet_pool_available != pool_0.nx_packet_pool_total)     
    {
        printf("ERROR!\n");
        test_control_return(1);
    }       

    /* Check the error counter.  */
    if ((error_counter) || (bound_flag != NX_TRUE) || (renew_flag != NX_TRUE))            
    {
        printf("ERROR!\n");
        test_control_return(1);
    }
    else
    {
        printf("SUCCESS!\n");
        test_control_return(0);
    }

}    
static UINT my_packet_process(NX_IP *ip_ptr, NX_PACKET *packet_ptr)
{            
ULONG       received_message_type;
ULONG       transaction_id;
    
    /* Update the prepend to point DHCPv6 message, IPv6 header, UDP header.  */
    packet_ptr -> nx_packet_prepend_ptr += (40 + 8);

    /* Extract the message type which should be the first byte.  */
    _nx_dhcpv6_utility_get_data(packet_ptr -> nx_packet_prepend_ptr, 1, &received_message_type);  

    /* Parse the transaction ID. */
    _nx_dhcpv6_utility_get_data((packet_ptr -> nx_packet_prepend_ptr + 1), 3, &transaction_id);

    /* Check for an illegal message type. */
    if (received_message_type == NX_DHCPV6_MESSAGE_TYPE_SOLICIT)
    {

        /* Send DHCPv6 Server Advertise response.  */
        dhcpv6_server_packet_response(transaction_id, 2);  
        dhcpv6_server_packet_response(transaction_id, 3);

    }
    else if(received_message_type == NX_DHCPV6_MESSAGE_TYPE_REQUEST)
    {      
        /* Send DHCPv6 Server Reply response.  */
        dhcpv6_server_packet_response(transaction_id, 5);  
        dhcpv6_server_packet_response(transaction_id, 6);
    }
    else if (received_message_type == NX_DHCPV6_MESSAGE_TYPE_RENEW)
    {          
        /* Send DHCPv6 Server Reply response.  */
        dhcpv6_server_packet_response(transaction_id, 8);  
        dhcpv6_server_packet_response(transaction_id, 9);
    }

    /* Relase the packet.  */
    nx_packet_release(packet_ptr);

    /* Return success.  */
    return(NX_SUCCESS);   
}    
static VOID   dhcpv6_server_packet_response(UINT transaction_id, UINT packet_index)
{
UINT        status;
NX_PACKET   *response_packet;
UCHAR       *data_ptr;  
UINT        data_size;
UINT        offset;
ULONG       message_type;
ULONG       message_word;


    /* Allocate a response packet.  */
    status =  nx_packet_allocate(&pool_0, &response_packet, NX_UDP_PACKET, TX_WAIT_FOREVER);
    
    /* Check status.  */
    if (status)
    {
        error_counter++; 
        return;
    }        

    /* Check the index.  */
    if (packet_index == 2)
    {
        data_ptr = (UCHAR *)pkt2; 
    }
    else if (packet_index == 3)
    {                           
        data_ptr = (UCHAR *)pkt3; 
    }   
    else if (packet_index == 5)
    {                           
        data_ptr = (UCHAR *)pkt5;   
    }
    else if (packet_index == 6)
    {                           
        data_ptr = (UCHAR *)pkt6; 
    }
    else if (packet_index == 8)
    {                           
        data_ptr = (UCHAR *)pkt8; 
    }
    else if (packet_index == 9)
    {                           
        data_ptr = (UCHAR *)pkt9;  
    }
    else
    {              

        error_counter ++;
        return;
    }  
            
    /* Set the data size.  */
    data_size = 198;

    /* Set the offset(physical header + IPv6 header).  */
    offset = 14 + 40;    
              
    /* Write the DHCPv6 Server response messages into the packet payload!  */
    status = nx_packet_data_append(response_packet, data_ptr, data_size, &pool_0, NX_NO_WAIT);

    /* Check status.  */
    if (status)
    {
        error_counter++;  
        return;
    }                

    /* Set the packet version.  */
    response_packet -> nx_packet_ip_version = NX_IP_VERSION_V6;

    /* Set the IP header pointer.  */
    response_packet -> nx_packet_ip_header = response_packet -> nx_packet_prepend_ptr + 14;

    /* Update the data pointer tp UDP + DHCPv6 message.  */
    response_packet -> nx_packet_prepend_ptr += offset;
    response_packet -> nx_packet_length -= offset;
                 
    /* Extract the message type which should be the first byte.  */
    _nx_dhcpv6_utility_get_data(response_packet -> nx_packet_prepend_ptr + 8, 1, &message_type);

    /* Clear memory to make the message header. */
    memset(&message_word, 0, sizeof(ULONG));

    /* Add the message type and transaction ID as the DHCPv6 header fields. */
    message_word = ((ULONG)message_type << 24); 

    /* Set the transaction ID.  */
    message_word |= (((ULONG)(0x0ffffff)) & (transaction_id));

    /* Adjust for endianness. */
    NX_CHANGE_ULONG_ENDIAN(message_word);                                       

    /* Copy the message header to the packet buffer. */
    memcpy(response_packet -> nx_packet_prepend_ptr + 8, &message_word, 4);   

    /* Set the packet interface.  */
    response_packet -> nx_packet_address.nx_packet_ipv6_address_ptr = &ip_0.nx_ipv6_address[0];

    /* Set the interface capablility flag to disable the UDP checksum check, (simplify operation)*/
    ip_0.nx_ipv6_address[0].nxd_ipv6_address_attached -> nx_interface_capability_flag |= NX_INTERFACE_CAPABILITY_UDP_RX_CHECKSUM;

    /* Receive the DHCPv6 Server response.  */
    _nx_udp_packet_receive(&ip_0, response_packet);

    return;
}     
/* This is the notification from the DHCPv6 Client task that it has changed 
   state in the DHCPv6 protocol, for example getting assigned an IPv6 lease and 
   achieving the bound state or an IPv6 lease expires and being reset to 
   the init state.   
*/
static VOID dhcpv6_state_change_notify(NX_DHCPV6 *dhcpv6_ptr, UINT old_state, UINT new_state)
{

                                        
    /* Check if the Client has been assigned an IPv6 lease. */
    if ((old_state == NX_DHCPV6_STATE_SENDING_REQUEST) && (new_state == NX_DHCPV6_STATE_BOUND_TO_ADDRESS))
    {         

        /* Update the flag.  */
        bound_flag = NX_TRUE;

        /* Check the available packet.  */
        if (pool_0.nx_packet_pool_available != pool_0.nx_packet_pool_total)  
        {
            error_counter++;
        }    
    }
          
    /* Check if the Client has been assigned an IPv6 lease. */
    if ((old_state == NX_DHCPV6_STATE_SENDING_RENEW) && (new_state == NX_DHCPV6_STATE_BOUND_TO_ADDRESS))
    {              
                     
        /* Update the flag.  */
        renew_flag = NX_TRUE;

        /* Check the available packet.  */
        if (pool_0.nx_packet_pool_available != pool_0.nx_packet_pool_total)  
        {
            error_counter++;
        }
    }                   
}
#else
#ifdef CTEST
VOID test_application_define(void *first_unused_memory)
#else
void netx_dhcpv6_packet_loss_test_application_define(void * first_unused_memory)
#endif
{
    printf("NetX Test:   DHCPv6 Packet Loss Test...................................N/A\n");
    test_control_return(3);
}
#endif
